/**
  ******************************************************************************
  * @file    py32f0xx_it.c
  * @author  MCU Application Team
  * @brief   Interrupt Service Routines.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) Puya Semiconductor Co.
  * All rights reserved.</center></h2>
  *
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include <stdio.h>
#include <string.h> // 包含 memset 的头文件
#include "py32f0xx_hal.h"

/* Private includes ----------------------------------------------------------*/

/* Private typedef -----------------------------------------------------------*/
// extern UART_HandleTypeDef UartHandle;
/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Private user code ---------------------------------------------------------*/

/* External variables --------------------------------------------------------*/


/******************************************************************************/
/*          Cortex-M0+ Processor Interruption and Exception Handlers          */
/******************************************************************************/
/**
 * @brief This function handles Non maskable interrupt.
 */
void NMI_Handler(void)
{
}

/**
 * @brief This function handles Hard fault interrupt.
 */
void HardFault_Handler(void)
{
  while (1)
  {
  }
}

/**
 * @brief This function handles System service call via SWI instruction.
 */
void SVC_Handler(void)
{
}

/**
 * @brief This function handles Pendable request for system service.
 */
void PendSV_Handler(void)
{
}

/**
 * @brief This function handles System tick timer.
 */
void SysTick_Handler(void)
{

  HAL_IncTick();
  tickMs++;
}

/**
 * @brief  串口中断公共服务函数
 * @param  无
 * @retval 无
 */
void USART1_IRQHandler(void)
{
  /* 接收寄存器非空（读数据准备好） */
  if (__HAL_UART_GET_FLAG(&uartHandle, UART_FLAG_RXNE))
  {
    rxDataBuf.data[rxDataBuf.Index++] = READ_REG(uartHandle.Instance->DR);
    if (rxDataBuf.Index == Rx_Data_Buf_Size)
    {
      rxDataBuf.Index = 0;
    }
  }
  /* 空闲中断 */
  if (__HAL_UART_GET_FLAG(&uartHandle, UART_FLAG_IDLE))
  {
    __HAL_UART_CLEAR_IDLEFLAG(&uartHandle);
    // printf("Index:%d\r\nRx_Data:%s\r\n",rxDataBuf.Index,rxDataBuf.data);
    centerParser();
    rxDataBuf.Index = 0;
    memset(rxDataBuf.data, 0, Rx_Data_Buf_Size);
  }
}
/**
  * @brief  This function handles PPP interrupt request.
  * @param  None
  * @retval None
  */
/*void PPP_IRQHandler(void)
{
}*/

/************************ (C) COPYRIGHT Puya *****END OF FILE****/
